package flc.ast.adapter;

import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyBackgroundColorBean;
import flc.ast.bean.MyBackgroundImageBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class BackgroundImageAdapter extends StkProviderMultiAdapter<MyBackgroundImageBean> {

    public BackgroundImageAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(80));
        addItemProvider(new BackgroundImageProvider());
    }

    private class BackgroundImageProvider extends BaseItemProvider<MyBackgroundImageBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_background_image;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyBackgroundImageBean bean) {
            Glide.with(baseViewHolder.itemView).load(bean.getImg()).into((ImageView) baseViewHolder.getView(R.id.ivBackgroundImageItemImg));
            if (bean.isSelect()) {
                baseViewHolder.getView(R.id.ivBackgroundImageItemSel).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.ivBackgroundImageItemSel).setVisibility(View.GONE);
            }
        }
    }
}
